/*commit*/

/*bisogna sistemare i css della libreria*/
/*tipo è il tipo di ricerca se  è "E" devo comporre un url esterno*/
function creatabella(param, dec, tipo) {

    $("#gbox_tabellare").remove();
    $("#presentazionetabella").remove();
    $("#salvezza").append('<table id="tabellare"> </table>');
    $("#salvezza").append('<div id="pager1"> </div>');
    if(dec == "Supermercati") {
        /*@TODO pippaiolo mode cambiare l'uri tenendo conto dell'htaccess!!*/
        if(tipo == "N")
            var url = "../cgi-bin/TrovaPerNomeSupermarket.php?Nome=" + param;
        if(tipo == "T")
            var url = "../cgi-bin/TrovaPerTipologiaSupermarket.php?Nome=" + param;
        if(tipo == "V")
            var url = "http://ltw1135.web.cs.unibo.it/vicino-a/ltw1213-supermercati/params/" + param[0] + "/" + param[1] + "/" + param[2];

        if(tipo == "R")

            var url = "http://ltw1135.web.cs.unibo.it/entro-il-raggio/ltw1213-supermercati/params/" + param[0] + "/" + param[1] + "/" + param[2];

    }
    if(dec == "Farmacie") {
        if(tipo == "N")
            var url = "../cgi-bin/TrovaPerNomeFarmacie.php?Nome=" + param;
        if(tipo == "T")

            var url = "../cgi-bin/TrovaPerTipologiaFarmacie.php?Nome=" + param;
        if(tipo == "V")
            var url = "http://ltw1135.web.cs.unibo.it/vicino-a/ltw1213-farmacie/params/" + param[0] + "/" + param[1] + "/" + param[2];
        if(tipo == "R")

            var url = "http://ltw1135.web.cs.unibo.it/entro-il-raggio/ltw1213-farmacie/params/" + param[0] + "/" + param[1] + "/" + param[2];

    }
    if(dec == "Equitalia") {
        if(tipo == "N")
            var url = "../cgi-bin/TrovaPerNomeAgenzie.php?Nome=" + param;
        if(tipo == "T")

            var url = "../cgi-bin/TrovaPerTipologiaAgenzie.php?Nome=" + param;
        if(tipo == "V")
            var url = "http://ltw1135.web.cs.unibo.it/vicino-a/ltw1213-equitalia/params/" + param[0] + "/" + param[1] + "/" + param[2];
        if(tipo == "R")

            var url = "http://ltw1135.web.cs.unibo.it/entro-il-raggio/ltw1213-equitalia/params/" + param[0] + "/" + param[1] + "/" + param[2];
    }
    jQuery("#tabellare").jqGrid({

        url : url, /*"../cgi-bin/PrendiEsterno.php?u="+url,*/
        datatype : "xml",
        mtype : "GET",
        colNames : ['category', 'name', 'address', 'opening'],
        colModel : [{
            name : 'category',
            index : 'category',
            xmlmap : "category",
            align : "left",
            sorttype : "float",
            width : 100
        }, {
            name : 'name',
            index : 'name',
            xmlmap : "name",
            align : "left",
            width : 200
        }, {
            name : 'address',
            index : 'address',
            xmlmap : "address",
            align : "left",
            sorttype : "float",
            width : 200
        },{
            name : 'opening',
            index : 'opening',
            xmlmap : "opening",
            align : "left",
            sorttype : "float",
            width : 200
        }],
        ondblClickRow: function(id) {
    		$("#primo").text( $(this).find("tr[id="+id+"] td").eq(0).text() );
    		$("#secondo").text( $(this).find("tr[id="+id+"] td").eq(1).text() );
    		$("#terzo").text( $(this).find("tr[id="+id+"] td").eq(2).text() );
    		$("#quarto").text( $(this).find("tr[id="+id+"] td").eq(3).text() );
    		$("#dialog").dialog( "open" );
    		dialogMap();
  			},
        height : 380,
        rowNum : 9,
        rowList : [9, 18, 27],
        pager: jQuery('#pager1'),
        viewrecords : true,
        loadonce : true,
        xmlReader : {
            root : "locations",
            row : "location",
            repeatitems : false,
            id : "ASIN"
        },
        caption : dec,
    }).navGrid('#pager1',{edit:false,add:false,del:false});	
    $("#dialog").dialog( { modal:true, autoOpen: false } );
	$(".ui-icon-search").remove();

}